import request from '@/utils/request'
// 查询商品通过类别和品牌
export const queryProductsByCategoryAndBrand = (
  categoryId,
  brandId,
  pageNum = 1,
  pageSize = 10
) => {
  return request({
    url: '/product/search',
    method: 'get',
    params: { categoryId, brandId, pageNum, pageSize }
  })
}

// 查询分类下的品牌
export const queryBrandsByCategory = (categoryId) => {
  return request({
    url: '/product/brands',
    method: 'get',
    params: { categoryId }
  })
}

// 查询品牌下的分类
export const queryCategoriesByBrand = (brandId) => {
  return request({
    url: '/product/categories',
    method: 'get',
    params: { brandId }
  })
}

// 根据关键词模糊查询商品
export const searchProductByName = (keyword, pageNum = 1, pageSize = 10) => {
  return request({
    url: '/product/search/name',
    method: 'get',
    params: { keyword, pageNum, pageSize }
  })
}

// 二级分类数据获取
// export const getSubCategoryAPI = (id) => {
//   return request({
//     url: '/category/sub/filter',
//     params: { id }
//   })
// }
// 分类基础列表数据获取
export const getSubCategoryListAPI = (data) => {
  return request({
    url: '/category/goods/temporary',
    method: 'POST',
    data
  })
}

// 获取分类id的数据
export const getTopCategoryAPI = (id) => {
  return request({
    url: '/category',
    params: { id }
  })
}
// 分类数据获取
export const getBannerAPI = (params = {}) => {
  // 默认为1 商品为2
  const { distributionSite = '1' } = params
  return request({
    url: '/home/banner',
    params: {
      distributionSite
    }
  })
}
// 获取全部的商品
export const getAllProduct = () => {
  return request({
    url: '/product/getAll',
    method: 'GET'
  })
}
